﻿using System.Windows;

namespace NMBP.View
{
    using GalaSoft.MvvmLight.Messaging;
    using Models;
    using NMBP_odb;
    using ViewModel;

    /// <summary>
    /// Interaction logic for EditCustomerFromAdminWindow.xaml
    /// </summary>
    public partial class EditCustomerFromAdminWindow : Window
    {
        public EditCustomerFromAdminWindow()
        {
            InitializeComponent();

            Messenger.Default.Register<Worker>(
                this,
                "CloseEditCustomerFromAdminWindow",
                (msg) =>
                {
                    AdminWindow adminWindow = new AdminWindow();
                    Messenger.Default.Send<Worker>(msg, "InitializeAdmin");
                    adminWindow.Show();
                    this.Close();
                });

            this.Closing += ((s,e)=>
                                 {
                                     Messenger.Default.Unregister(this);
                                     ViewModelLocator.ClearEditCustomerFromAdminViewModel();
                                 });
        }
    }
}
